"""
编写一个装饰器，用于缓存函数的结果，以便在相同参数调用时返回缓存的结果
"""
import time
from time import sleep


def cache_demo(func):
    cache_dic = {}
    def inner(*args):
        if args in cache_dic.keys():
            return cache_dic[args]
        res = func(*args)
        cache_dic[args] = res
        return res
    return inner


@cache_demo
def show(a, b):
    time.sleep(5)
    return a + b


if __name__ == '__main__':
    print(show(1,6))
    print(show(1,6))
    print(show(1,6))
    print(show(1,6))
